package com.negative.logic;

import com.negative.activities.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class HomeScreenShortcutAdapter extends BaseAdapter {

	private Context context;
	private String[] icons;
	
    public HomeScreenShortcutAdapter(Context context) {
    	this.context = context;
    	this.icons  = new View(context).getResources().getStringArray(R.array.iconsNames) ;
    }

    @Override
    public int getCount() {
        return icons.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	 
			View gridView;
	 
			if (convertView == null) {
	 
				gridView = new View(context);

				gridView = inflater.inflate(R.layout.grid_layout, null);
	 
				// set value into textview
				TextView textView = (TextView) gridView
						.findViewById(R.id.grid_item_label);
				textView.setText(icons[position]);
				
				switch (position) {
				case 0:
					textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.eventsicon, 0, 0);
					break;
				case 1:
					textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.searchicon, 0, 0);
					break;
				}
				
			} else {
				gridView = (View) convertView;
			}
	 
			return gridView;
	}

}